<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Migrating from GtkTooltips to GtkTooltip</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GTK+ 2 Reference Manual">
<link rel="up" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+">
<link rel="prev" href="gtk-migrating-GtkBuilder.html" title="Migrating from libglade to GtkBuilder">
<link rel="next" href="gtk-migrating-entry-icons.html" title="Migrating from SexyIconEntry to GtkEntry">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="gtk-migrating-GtkBuilder.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="migrating.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GTK+ 2 Reference Manual</th>
<td><a accesskey="n" href="gtk-migrating-entry-icons.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="gtk-migrating-tooltips"></a>Migrating from GtkTooltips to GtkTooltip</h2></div></div></div>
<p>
    GTK+ 2.12 brings a completely new tooltip implementation which
    allows many things that were not possible with the old 
    <a class="link" href="GtkTooltips.html" title="GtkTooltips"><span class="type">GtkTooltips</span></a> interface. The new possibilities are explained
    in more detail in the section about <a class="link" href="GtkTooltip.html" title="GtkTooltip"><span class="type">GtkTooltip</span></a>. 
  </p>
<p>
    A number of complications of the old API have been removed:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
        Tooltips can not be grouped anymore. The old tooltips
        API allowed this by using multiple <a class="link" href="GtkTooltips.html" title="GtkTooltips"><span class="type">GtkTooltips</span></a> objects.
        We believe that the timeout behaviour of the new tooltips 
        implementation is better and makes it unnecessary to use 
        grouping as a way to overcome shortcomings of the 
        fast-tooltips mode.
      </p></li>
<li class="listitem"><p>
        Timeouts can not be set individually anymore. Instead
        there are settings <a class="link" href="GtkSettings.html#GtkSettings--gtk-tooltip-timeout" title='The "gtk-tooltip-timeout" property'><span class="type">"gtk-tooltip-timeout"</span></a>, 
        <a class="link" href="GtkSettings.html#GtkSettings--gtk-tooltip-browse-timeout" title='The "gtk-tooltip-browse-timeout" property'><span class="type">"gtk-tooltip-browse-timeout"</span></a> and
        <a class="link" href="GtkSettings.html#GtkSettings--gtk-tooltip-browse-mode-timeout" title='The "gtk-tooltip-browse-mode-timeout" property'><span class="type">"gtk-tooltip-browse-mode-timeout"</span></a> to influence
        the behaviour of tooltips globally.
      </p></li>
</ul></div>
<p>
  </p>
<p>
    Here is an example of setting a tooltip on a widget with the old API:
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">GtkTooltips</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">tooltips </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="GtkTooltips.html#gtk-tooltips-new">gtk_tooltips_new</a></span><span class="normal"> </span><span class="symbol">();</span><span class="normal">     </span>
<span class="function"><a href="GtkTooltips.html#gtk-tooltips-set-tip">gtk_tooltips_set_tip</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">tooltips</span><span class="symbol">,</span><span class="normal"> widget</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"Some tips"</span><span class="symbol">,</span><span class="normal"> <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
  </p>
<p>
    Using the new tooltips API, it is no longer necessary to create 
    an object:
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="GtkWidget.html#gtk-widget-set-tooltip-text">gtk_widget_set_tooltip_text</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">widget</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"Some tips"</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
  </p>
<p>
    Similarly, setting a tooltip on a <a class="link" href="GtkToolItem.html" title="GtkToolItem"><span class="type">GtkToolItem</span></a> gets
    simplified from
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="GtkToolItem.html#gtk-tool-item-set-tooltip">gtk_tool_item_set_tooltip</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">toolitem</span><span class="symbol">,</span><span class="normal"> toolbar</span><span class="symbol">-&gt;</span><span class="normal">tooltips</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"tool tip"</span><span class="symbol">,</span><span class="normal"> <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
    to
    </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="GtkToolItem.html#gtk-tool-item-set-tooltip-text">gtk_tool_item_set_tooltip_text</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">toolitem</span><span class="symbol">,</span><span class="normal"> text</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
  </p>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18</div>
</body>
</html>